package com.renwei.yunlong.utils;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;

/**
 * Project :  yunna.
 * Package name: com.renwei.yunlong.utils
 * Created by :  Benjamin.
 * Created time: 2018/1/16 13:37
 * Changed by :  Benjamin.
 * Changed time: 2018/1/16 13:37
 * Class description:
 */

public class UtilBitmap {
    public static String getPixColor(Context context, Resources resource, int id) {
        String color = "";
        Bitmap bitmap = BitmapFactory.decodeResource(resource, id);
        if (null != bitmap) {
            int pixel = bitmap.getPixel(200, 5);
            //获取颜色
            int redValue = Color.red(pixel);
            int greenValue = Color.green(pixel);
            int blueValue = Color.blue(pixel);
            color = "#" + Integer.toHexString(pixel).toUpperCase();
            bitmap.recycle();
        }
        return color.length() == 0 ? "#689DF8" : color;
    }
}
